package controllers;

import models.sys.AdminUser;
import packaged.SessionManager;
import play.mvc.*;
import supporter.RT;


public class Application extends Controller {

    public static void testLogin(){
        //设置用户登录信息
        AdminUser user = AdminUser.find("byUsername", "adinlead").first();
        SessionManager.setSession(user, false);
        SessionManager.setAttribute("uid", String.valueOf(user.id));
        if (user.role != null) {
            SessionManager.setAttribute("rid", String.valueOf(user.role.id));
        }
        renderJSON(RT.success());
    }

    /**
     * @function 调试Ajax专用接口, 勿删
     */
    public static void test() {
//        List<AdminUser> adminUserList = AdminUser.findAll();
//        for (AdminUser adminUser : adminUserList) {
//            adminUser.password = "111111";
//            AdminPasswordHelper.encryptPassword(adminUser);
//            adminUser.save();
//        }
        renderJSON(RT.parameterError());
    }

}